﻿@model Api.Model.Method
@{
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
@section seo{
    <title>@ViewBag.Title</title>
}
@section script{
    <script type="text/javascript">
        $(function () {
            editors.push('Description');
            editors.push('ResultDemo');
            editors.push('ResultDesc');
            window.postUrl = '@Url.Action("Edit",new {Area="Admin", Th.ProjectId })';
            window.form = $('#form1');
            bindValidate(ajaxSubmit, form);
            initData();
        });

        function initData() {
            var httpMethod = '@(Model?.HttpMethod)';
            var limit = '@(Model?.IsTimeLimit)'.toLocaleLowerCase();
            var isNeedLogin = '@(Model?.IsNeedLogin)'.toLocaleLowerCase();
            $('[name="HttpMethod"]').filter(function () {
                return $(this).val() == httpMethod;
            }).prop('checked', true);
            $('[name="IsTimeLimit"]').filter(function () {
                return $(this).val() == limit;
            }).prop('checked', true);
            $('[name="IsNeedLogin"]').filter(function () {
                return $(this).val() == isNeedLogin;
            }).prop('checked', true);
        }
        function ajaxSubmit() {
            msgBox.showMsgWait("正在提交");
            var data = $(form).serialize();
            $.post(postUrl, data, function (ajaxMsg) {
                msgBox.showMsg(ajaxMsg);
                if (ajaxMsg.status == 1) {
                    if (ajaxMsg.url != undefined && ajaxMsg.url != '') {
                        location.href = ajaxMsg.url;
                    }
                }
            })
        }
    </script>
}
<form id="form1">
    @Html.AntiForgeryToken()
    <!--左邊菜單--開始-->
    @Html.Partial("_LeftMenu")
    <!--左邊菜單--結束-->
    <!--右邊--B-->
    <div class="shanpin_right">
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk">&nbsp;</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="submit" id="btnSave" value="Save" class="save_continue button button-glow button-rounded button-royal" />
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("List", new {Th.ProjectId})">Return</a>
                @if (Model != null && Model.Id > 0)
                {
                    <a target="_blank" class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Create","MethodParameter", new {Th.ProjectId,methodId=Model.Id})">參數修改</a>
                }
                @if (Model != null && Model.CategoryId > 0 && Model.Id > 0)
                {
                    <a class="save_continue button button-glow button-rounded button-royal"  target="_blank" href="@Url.Action("Detail","Method",new{Area="",MethodId=Model.Id,Model.CategoryId,Th.ProjectId})">預覽</a>
                }
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div style="height: 20px;"></div>
        @Html.Partial("_Message", new TipMessage() { TipStatus = TipStatus.Error, Message = ViewBag.Error })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Info, Message = ViewBag.Info })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Warning, Message = ViewBag.Warning })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Success, Message = ViewBag.Success })
        <input type="hidden" value="@(Model?.Id)" name="Id" />
        <input type="hidden" value="@Th.ProjectId" name="projectId" />
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>名稱</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="text" name="name" class="form-contds required" value="@(Model?.Name)" />
                <span id="name-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>接口地址</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="text" name="url" class="form-contds required" value="@(Model?.Url)" />
                <span id="url-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>請求方式</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <label><input name="HttpMethod" type="radio" value="@MethodType.Get" checked="checked" />Get</label>
                <label><input name="HttpMethod" type="radio" value="@MethodType.Post" />Post</label>
                <span id="HttpMethod-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>是否限制訪問次數</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <label><input name="IsTimeLimit" type="radio" value="false" checked="checked" />否</label>
                <label><input name="IsTimeLimit" type="radio" value="true" />是</label>
                <span id="IsTimeLimit-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>是否需要登錄</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <label><input name="IsNeedLogin" type="radio" value="false" checked="checked" />否</label>
                <label><input name="IsNeedLogin" type="radio" value="true" />是</label>
                <span id="istimelimit-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>請求等級</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input name="RequestLevel" value="@(Model?.RequestLevel)" class="form-contds" />
                <span id="RequestLevel-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>支持格式</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input name="SupportFomats" value="@(Model?.SupportFomats)" class="form-contds" />
                <span id="SupportFomats-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>接口描述</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                @Html.TextAreaFor(s => s.Description, new { @class = "form-contds", @style = "width:800px;height:600px" })
                <span id="Description-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>Json返回示例</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                @Html.TextAreaFor(s => s.ResultDemo, new { @class = "form-contds", @style = "width:800px;height:600px" })
                <span id="ResultDemo-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>接口返回值说明</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                @Html.TextAreaFor(s => s.ResultDesc, new { @class = "form-contds", @style = "width:800px;height:600px" })
                <span id="ResultDesc-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk">&nbsp;</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="submit" id="btnSave" value="Save" class="save_continue button button-glow button-rounded button-royal" />
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("List", new {Th.ProjectId})">Return</a>
                @if (Model != null && Model.Id > 0)
                {
                    <a target="_blank" class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Create","MethodParameter", new {Th.ProjectId,methodId=Model.Id})">參數設置</a>
                }
                @if (Model != null && Model.CategoryId > 0 && Model.Id > 0)
                {
                    <a class="save_continue button button-glow button-rounded button-royal" target="_blank" href="@Url.Action("Detail","Method",new{Area="",MethodId=Model.Id,Model.CategoryId,Th.ProjectId})">預覽</a>
                }
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
    </div>
</form>
